package servlet;

import service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author : liuchangling
 * @Descrition :
 * @Date： Created in 11:01 下午 2021/5/29
 */
@WebServlet(name = "DeleteUserServlet",urlPatterns = "/delete")
public class DeleteUserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String s=request.getParameter("sno").trim();
        int sno=Integer.parseInt(s);
        System.out.println(sno);
        UserService userService=new UserService();
        boolean isSuccess=userService.deleteUserService(sno);
        if(isSuccess==true){
            request.getSession().setAttribute("isDeleteClass",true);
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
